﻿namespace ApophysisCS
{
    #region Imported Namespaces
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
    #endregion

    /// <summary>
    /// Interaction logic for Editor.xaml
    /// </summary>
    public partial class EditorWindow : Window
    {
        public EditorWindow()
        {
            InitializeComponent();
            this.AdviseClosingEvent();
        }

        internal void CloseWindow()
        {
            this.UnadviseClosingEvent();
            this.Close();
        }

        private void AdviseClosingEvent()
        {
            this.Closing += this.EditorWindow_Closing;
        }

        private void UnadviseClosingEvent()
        {
            this.Closing -= this.EditorWindow_Closing;
        }

        private void EditorWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)(() => { this.Hide(); }));
            e.Cancel = true;
        }
    }
}
